//
//  SetTableViewController.m
//  MobileGameLiving2
//
//  Created by reflection on 15/8/31.
//  Copyright (c) 2015年 李旭东. All rights reserved.
//

#import "SetTableViewController.h"
#import "LoadViewController.h"
#import "UIImage+Circle.h"

@interface SetTableViewController ()
@property (nonatomic,strong)UIImageView *userImage;
@property (nonatomic,strong)UILabel *userName;
@end

@implementation SetTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//    [self.navigationController setNavigationBarHidden:YES];
    UIView *userInfo = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 375, 150)];
    userInfo.backgroundColor = [UIColor lightGrayColor];
    self.tableView.tableHeaderView = userInfo;
    UIImageView *userImage = [[UIImageView alloc]initWithFrame:CGRectMake(135, 15, 100, 100)];
//    userImage.image = [UIImage imageNamed:@"111.jpg"];
    UIImage *image = [UIImage imageNamed:@"222.jpg"];
    image = [UIImage scaleToSize:image size:CGSizeMake(100, 100)];
    userImage.image = [UIImage circleImageWithImage:image borderWidth:4 borderColor:[UIColor blueColor]];
    UILabel *userName = [[UILabel alloc]initWithFrame:CGRectMake(35, 110, 40, 15)];
    userName.text = @"111";
    self.userImage = userImage;
    self.userName = userName;
    [userInfo addSubview:userImage];
    [userImage addSubview:userName];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return 4;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *setid = @"SetCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:setid];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:setid];
        if (indexPath.row == 0) {
            cell.textLabel.text = @"登录";
            
        }else if (indexPath.row == 1){
            UISwitch *wifiSwitch = [[UISwitch alloc]init];
            wifiSwitch.on = YES;
            if (wifiSwitch.on == YES) {
                cell.textLabel.text = @"wifi网络";
            }else if (wifiSwitch.on == NO){
                cell.textLabel.text = @"请更换wifi网络";
            }
            cell.accessoryView = wifiSwitch;
        }else if (indexPath.row == 2) {
            cell.textLabel.text = @"333";
        }else {
            cell.textLabel.text = @"444";
        }
        
    }
    // Configure the cell...
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        LoadViewController *lVC = [[LoadViewController alloc]initWithNibName:@"LoadViewController" bundle:nil];
        [self.navigationController pushViewController:lVC animated:YES];
    }
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here, for example:
    // Create the next view controller.
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil];
    
    // Pass the selected object to the new view controller.
    
    // Push the view controller.
    [self.navigationController pushViewController:detailViewController animated:YES];
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
